package com.sphd.beautysalon.adapters;

import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.beautysalon.R;
import com.sphd.beautysalon.base.RestaurantUrl;
import com.sphd.beautysalon.base.RestaurantsApplication;
import com.sphd.beautysalon.info.StaffInfo;
import com.wzh.frame.views.RoundImageView;

import java.util.List;

/**
 * Created by Hu on 2016/12/22.
 */

public class StaffAdapter extends BaseQuickAdapter<StaffInfo> {
    public StaffAdapter(int layoutResId, List<StaffInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, StaffInfo staffInfo) {
        baseViewHolder
                .setText(R.id.vip_name, staffInfo.getStaff_name())
                .setVisible(R.id.staff_number,true)
                .setVisible(R.id.del_btn,staffInfo.getStaff_auth()==3?false:true)
                .addOnClickListener(R.id.del_btn)
                .setText(R.id.staff_number,staffInfo.getStaff_phone())
                .setText(R.id.vip_registertime, getJobTitle(staffInfo.getStaff_auth()));
        RoundImageView roundImageView=baseViewHolder.getView(R.id.vip_img);
        setImage(roundImageView,staffInfo.getStaff_photo());
    }
    public void setImage(ImageView image, String url) {
        ImageLoader imageLoader = RestaurantsApplication.getImageLoader();
        ImageLoader.ImageListener listener = ImageLoader.getImageListener(image,
                R.mipmap.moren, R.mipmap.moren);
        imageLoader.get(RestaurantUrl.Httpimg + url, listener);
    }
    private String getJobTitle(int auth) {
        String jobTitle = null;
        switch (auth) {
            case 1:
                jobTitle = "贝塔超管";
                break;
            case 2:
                jobTitle = "超管";
                break;
            case 3:
                jobTitle = "店长";
                break;
            case 4:
                jobTitle = "接单员";

                break;
            case 5:
                jobTitle = "服务员";

                break;
            case 6:
                jobTitle = "用户";
                break;
            default:
                jobTitle = "错误";

                break;
        }
        return jobTitle;
    }
}
